package com.smmisia.article.controller;

import com.smmisia.article.request.CreateGroupRequest;
import com.smmisia.article.response.socket.FriendResponse;
import com.smmisia.article.response.socket.GroupResponse;
import com.smmisia.article.service.GroupService;
import com.smmisia.common.Result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 群组相关接口
 */
@RestController
@RequestMapping("/group")
@Tag(name = "群组相关接口", description = "群组相关接口")
public class GroupController {

    @Autowired
    private GroupService groupService;

    /**
     * 加入群组
     * @param groupId
     * @return
     */
    @GetMapping("/add")
    public Result<Boolean> addGroup(Integer groupId) {
        return groupService.addGroup(groupId);
    }

    /**
     * 创建群组
     * @param request
     * @return
     */
    @PostMapping("/create")
    public Result<Boolean> createGroup(@Valid @RequestBody CreateGroupRequest request) {
        return groupService.createGroup(request);
    }

    /**
     * 退出群组
     * @param groupId
     * @return
     */
    @GetMapping("/quit")
    public Result<Boolean> quitGroup(@RequestParam Integer groupId) {
        return groupService.quitGroup(groupId);
    }

    /**
     * 解散群组
     * @param id
     * @return
     */
    @GetMapping("/remove")
    public Result<Boolean> removeGroup(@RequestParam Integer id) {
        return groupService.removeGroup(id);
    }

    /**
     * 获取群组成员
     * @param groupId
     * @return
     */
    @GetMapping("/listMember")
    public Result<FriendResponse> listGroupMember(@RequestParam Integer groupId) {
        return groupService.listGroupMember(groupId);
    }

    /**
     * 获取群组列表
     * @return
     */
    @GetMapping("/list")
    public Result<GroupResponse> listGroup() {
        return groupService.listGroup();
    }



}
